package show.me.the.money.util.exp.standard;

import java.util.List;

import show.me.the.money.util.context.Context;
import show.me.the.money.util.exp.ExpRunner;
import show.me.the.money.util.exp.Expression;

@SuppressWarnings("unchecked")
public class IF extends Expression {

	public Object run(List lsExp, Context ctx) {
		try {
			List la1 = (List)lsExp.get(1);
			boolean b = (Boolean)(ExpRunner.run(la1, ctx));
			List la2 = null;
			if (b) {
				la2 = (List)lsExp.get(2);
			} else {
				la2 = (List)lsExp.get(3);
			}
			return ExpRunner.run(la2, ctx);
		} 
		catch (Exception e) {
			logger.fatal("run JSONException:", e);
		}
		return null;
	}

}
